﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:WpfShaderEffects.Experimental">

   <Style TargetType="{x:Type local:EffectRepeater}">
      <Setter Property="HorizontalContentAlignment" Value="Center"/>
      <Setter Property="VerticalContentAlignment" Value="Center"/>
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:EffectRepeater}">
               <Grid
                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
                  Margin="{TemplateBinding Padding}" 
                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                  >
                  <ItemsControl
                     ItemsSource="{TemplateBinding BeforeContentEffects}"
                     Margin="0"
                     >
                     <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                           <Grid
                              Margin="0"
                              IsHitTestVisible="False" 
                              HorizontalAlignment="Stretch"
                              VerticalAlignment="Stretch"
                              />
                        </ItemsPanelTemplate>
                     </ItemsControl.ItemsPanel>
                     <ItemsControl.ItemTemplate>
                        <DataTemplate>
                           <Rectangle 
                              HorizontalAlignment="Stretch"
                              VerticalAlignment="Stretch"
                              Effect="{Binding Mode=OneWay}"
                              >
                              <Rectangle.Fill>
                                 <VisualBrush 
                                 Visual="{Binding ElementName=PART_Content,Mode=OneWay}" 
                                 AutoLayoutContent="False"
                                 Stretch="None"
                                 >
                                 </VisualBrush>
                              </Rectangle.Fill>
                           </Rectangle>
                        </DataTemplate>
                     </ItemsControl.ItemTemplate>
                  </ItemsControl>
                  <Grid 
                     Margin="0"
                     Visibility="{TemplateBinding ContentVisibility}">
                     <ContentPresenter 
                        Margin="0"
                        x:Name="PART_Content" 
                        RecognizesAccessKey="True"
                        />
                  </Grid>
               </Grid>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <Style TargetType="{x:Type local:EffectStacker}">
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:EffectStacker}">
               <ContentControl 
                  x:Name="PART_Root"
                  Margin="{TemplateBinding Margin}">
                  <ContentPresenter 
                     x:Name="PART_Content" 
                     HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                     Margin="{TemplateBinding Padding}" 
                     VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
                     SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                     RecognizesAccessKey="True"
                     />
               </ContentControl>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>
</ResourceDictionary>
